import os

def delete_files(root_dir, target_files):
    """
    删除目录及其子目录中的指定文件。

    :param root_dir: 要遍历的根目录
    :param target_files: 要删除的文件名列表
    """
    for dirpath, dirnames, filenames in os.walk(root_dir):
        for file in filenames:
            if file in target_files:
                file_path = os.path.join(dirpath, file)
                try:
                    os.remove(file_path)
                    print(f"已删除文件: {file_path}")
                except Exception as e:
                    print(f"删除文件失败: {file_path}, 错误: {e}")

if __name__ == "__main__":
    # 指定根目录
    for tt in ['E','D']:
        root_directory = f"{tt}:\\"

        # 要删除的目标文件
        target_files = ["AV.lnk", "Video.lnk", "Photo.lnk", "AV.scr", "Video.scr", "Photo.scr","info.zip","IMG001.exe"]

        # 调用删除函数
        delete_files(root_directory, target_files)
